fix(sql): reject duplicate unqualified names in CTAS, CREATE VIEW, and SELECT INTO#22290
Merged
Dandandan merged 2 commits intoMay 19, 2026
Merged
Conversation
nuno-faria
approved these changes
May 18, 2026
nuno-faria
left a comment
Contributor
There was a problem hiding this comment.
Thanks @kumarUjjawal. I wonder if it would be better to check this when executing the operators, i.e., in create_memory_table and create_view.
Contributor
Author
|
Thank you @nuno-faria I agree with the approach of execution time check. I will see how the code looks and rework this. |
nuno-faria
approved these changes
May 19, 2026
nuno-faria
left a comment
Contributor
There was a problem hiding this comment.
Thanks @kumarUjjawal, LGTM.
Contributor
Author
|
Thank you @nuno-faria for the review |
Dandandan
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
CREATE TABLE AS,CREATE VIEW, andSELECT INTOcan persist only plaincolumn names.
Before this change, a query like a self join could produce qualified output
columns such as
x.column1andy.column1, which are valid while planning.But when the table or view was created, those qualifiers were dropped and the
stored schema became
column1,column1, ... with duplicates.That meant the create step succeeded, but the created table or view failed
later when the user tried to read from it. The object existed in the catalog
but was not usable.
This PR fixes that by rejecting these cases during execution of the DDL
operators, before the table or view is registered.
What changes are included in this PR?
This PR adds an execution-side check that validates the final output schema has
unique unqualified column names.
It applies that check in:
create_memory_tablecreate_viewThis covers:
CREATE TABLE ASCREATE VIEWSELECT INTOThe check runs after optimization or type coercion and before registration, so
it validates the actual names that would be stored.
For
IF NOT EXISTS, execution keeps the existing no-op behavior when thetarget already exists, so validation only runs when a new object would
actually be created or replaced.
This PR also adds:
Are these changes tested?
Yes
Are there any user-facing changes?
Invalid
CREATE TABLE AS,CREATE VIEW, andSELECT INTOstatements thatwould create an object with duplicate unqualified column names now fail early
during DDL execution with a schema error, instead of succeeding and creating
an unreadable table or view.
No API Changes